home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_400
/
414_01
/
comm3.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-11-15
|
35KB
|
1,216 lines
/***********************************************************************/
/* COMM3.C - Commands K-O */
/* This file contains all commands that can be assigned to function */
/* keys or typed on the command line. */
/***********************************************************************/
/*
* THE - The Hessling Editor. A text editor similar to VM/CMS xedit.
* Copyright (C) 1991-1993 Mark Hessling
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to:
*
* The Free Software Foundation, Inc.
* 675 Mass Ave,
* Cambridge, MA 02139 USA.
*
*
* If you make modifications to this software that you feel increases
* it usefulness for the rest of the community, please email the
* changes, enhancements, bug fixes as well as any and all ideas to me.
* This software is going to be maintained and enhanced as deemed
* necessary by the community.
*
* Mark Hessling email: M.Hessling@gu.edu.au
* 36 David Road Phone: +61 7 849 7731
* Holland Park Fax: +61 7 875 5314
* QLD 4121
* Australia
*/
/*
$Header: C:\THE\RCS\comm3.c 1.4 1993/09/01 16:25:40 MH Interim MH $
*/
#include <stdio.h>
#include "the.h"
#include "proto.h"
/*#define DEBUG 1*/
/*-------------------------- external data ----------------------------*/
extern LINE *next_line,*curr_line;
extern VIEW_DETAILS *vd_current,*vd_first,*vd_mark;
extern char current_screen;
extern SCREEN_DETAILS screen[MAX_SCREENS]; /* screen structures */
extern char display_screens; /* number of screens */
extern char current_file; /* pointer to current file */
extern WINDOW *foot,*error_window;
extern bool error_on_screen;
extern char *rec;
extern unsigned short rec_len;
extern char mode_insert; /* defines insert mode toggle */
extern char in_profile; /* indicates if processing profile */
extern char *temp_cmd;
extern char *last_target;
/*man-start*********************************************************************
COMMAND
left_arrow - move the cursor left one column
SYNTAX
** effective only if bound to a key **
DESCRIPTION
The left_arrow command moves the cursor left one column in the
current window. Scrolling of the main window horizontally, occurs
if the cursor is at the left-most column and the left-most column
is not the first column of the line.
COMPATIBILITY
XEDIT: N/A
KEDIT: Equivalent of CURSOR LEFT
SEE ALSO
Right_arrow
STATUS
Complete.
**man-end**********************************************************************/
#ifdef PROTO
int Left_arrow(char *params)
#else
int Left_arrow(params)
char *params;
#endif
/***********************************************************************/
{
/*------------------------- external data -----------------------------*/
extern bool CMDARROWSTABLRx;
/*--------------------------- local data ------------------------------*/
unsigned short x,y;
short col,old_col;
/*--------------------------- processing ------------------------------*/
#ifdef TRACE
trace_function("comm3.c: Left_arrow");
#endif
getyx(CURRENT_WINDOW,y,x);
/*---------------------------------------------------------------------*/
/* For all windows, if we are not at left column, move 1 pos to left. */
/*---------------------------------------------------------------------*/
if (x > 0)
{
wmove(CURRENT_WINDOW,y,x-1);
#ifdef TRACE
trace_return();
#endif
return(RC_OK);
}
/*---------------------------------------------------------------------*/
/* For all windows, determine if CMDARROWSTABLRx is set for tabbing or */
/* scrolling and act accordingly. */
/*---------------------------------------------------------------------*/
switch(CURRENT_VIEW->current_window)
{
case WINDOW_MAIN:
if (CMDARROWSTABLRx)
{
if (CURRENT_VIEW->prefix)
{
Tabpre("");
wmove(CURRENT_WINDOW,y,getmaxx(CURRENT_WINDOW)-1);
}
else
wmove(CURRENT_WINDOW,y,getmaxx(CURRENT_WINDOW)-1);
}
else
{
if (CURRENT_VIEW->verify_start != CURRENT_VIEW->verify_col)
{
old_col = (CURRENT_VIEW->verify_col-1);
x = CURRENT_SCREEN.cols / 2;
col = max((short)CURRENT_VIEW->verify_start,
(short)(CURRENT_VIEW->verify_col-1) - (short)x);
CURRENT_VIEW->verify_col = col;
show_page();
x = old_col - (CURRENT_VIEW->verify_col-1);
wmove(CURRENT_WINDOW,y,x-1);
}
}
break;
case WINDOW_PREFIX:
if (CMDARROWSTABLRx)
if (CURRENT_VIEW->prefix)
{
Tabpre("");
wmove(CURRENT_WINDOW,y,getmaxx(CURRENT_WINDOW)-1);
}
break;
case WINDOW_COMMAND:
if (CMDARROWSTABLRx)
wmove(CURRENT_WINDOW,y,getmaxx(CURRENT_WINDOW)-1);
break;
default:
break;
}
#ifdef TRACE
trace_return();
#endif
return(RC_OK);
}
/*man-start*********************************************************************
COMMAND
locate - make line identified by target become the current line
SYNTAX
[Locate] target
DESCRIPTION
The LOCATE command looks for the next or previous occurrence of the
specified target. If no parameter is supplied, LOCATE
searches for the string that was used as the last string target, if
such a string target exists.
COMPATIBILITY
XEDIT: Does not support [subcommand] option.
KEDIT: Compatible. (See bleow)
Does not support not,and,or combinations of string targets.
ie ~,& and | not supported.
STATUS
Complete.
**man-end**********************************************************************/
#ifdef PROTO
int Locate(char *params)
#else
int Locate(params)
char *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
unsigned short x,y;
short rc;
/*--------------------------- processing ------------------------------*/
#ifdef TRACE
trace_function("comm3.c: Locate");
#endif
/*---------------------------------------------------------------------*/
/* If no parameter is specified, use the last_target. If that doesn't */
/* exist, error. */
/*---------------------------------------------------------------------*/
if (strcmp(params,"") == 0)
{
if (strcmp(last_target,"") == 0)
{
display_error(39,(char *)"");
#ifdef TRACE
trace_return();
#endif
return(RC_INVALID_OPERAND);
}
rc = command_line(last_target,COMMAND_ONLY_FALSE);
#ifdef TRACE
trace_return();
#endif
return(rc);
}
rc = command_line(params,COMMAND_ONLY_FALSE);
#ifdef TRACE
trace_return();
#endif
return(rc);
}
/*man-start*********************************************************************
COMMAND
lowercase - change uppercase characters to lowercase
SYNTAX
LOWercase [target]
DESCRIPTION
The LOWERCASE command changes all uppercase characters in the target
to lowercase. All other characters remain untouched.
COMPATIBILITY
XEDIT: Equivalent of LOWERCAS command.
KEDIT: Compatible.
STATUS
Complete.
**man-end**********************************************************************/
#ifdef PROTO
int Lowercase(char *params